local InputEntrence = class("InputEntrence",Event)

SgsUI = CS.SgsUI

AppPath = CS.UnityEngine.Application.dataPath

UI = require("Input.UI")

function InputEntrence:ctor(param)
    self.root = UI.newObject(param.root)
    self.path = param.path
end

function InputEntrence:render()
    self:clear()

    local data = SgsUI.GameUtility.SafeReadAllBytes(self.path)
    local View = json.decode(data)

    local arr = string.split(self.path,"/")
    local file = arr[#arr]
    local arr2 = string.split(file,".")
    local node_name = arr2[1]
    
    local nodes = View.children

    local transform = self.root:getRectTransform()

    transform.name = node_name
    transform.sizeDelta = Vector2(View.width,View.height)
    transform.anchoredPosition = Vector2(0,0)

    local ViewNode = require("Input.Entity.ViewNode")

    ViewNode:renderChildren(nodes,self.root)
end

function InputEntrence:clear()
    local children = self.root:getChildren()
    for k,v in ipairs(children) do
        v:removeSelf()
    end
end

return InputEntrence

